package xin.qixia.robot.core.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import xin.qixia.robot.core.RobotMessageDispatcher;
import xin.qixia.robot.core.RobotMessageListenerProcessor;

/**
 * 自动配置
 *
 * @author wangkaixin
 * @date 2025/5/23 14:41
 */
@Configuration
public class RobotMessageAutoConfiguration {

    /**
     * 消息分发
     *
     * @return
     */
    @Bean
    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    public static RobotMessageDispatcher robotMessageDispatcher() {
        return new RobotMessageDispatcher();
    }

    /**
     * 消息监听
     *
     * @param robotMessageDispatcher
     * @return
     */
    @Bean
    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    public static RobotMessageListenerProcessor robotMessageListenerProcessor(RobotMessageDispatcher robotMessageDispatcher) {
        return new RobotMessageListenerProcessor(robotMessageDispatcher);
    }
}